<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <script src="./js/earthsdk.js"></script>
    <!-- 自定义Css样式 -->
    <link rel="stylesheet" href="./css/example1.css">
    <title>拾取对象pick</title>
    <style>
        html,
        body,
        #app {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }

        #box {
            height: 100px;
            text-align: center;
        }

        #box>h3 {
            padding-bottom: 10px;
            border-bottom: 2px solid #9d9a9a;
        }

        #info {
            height: auto;
            word-wrap: break-word;
            word-break: break-all;
            overflow: hidden;
            font-size: 14px;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <div id="panel">
        <div id="box">
            <h3>pickPosition返回值</h3>
            <p id="info"></p>
        </div>
    </div>
    <script>
        /** ---------------------------------地球创建------------------------------------**/

        // Vue中引入方式：import { ESObjectsManager } from 'esobjs-xe2-plugin/dist-node/esobjs-xe2-plugin-main';

        const { ESObjectsManager } = XE2['esobjs-xe2-plugin-main']
        const objm = new ESObjectsManager();
        window.g_objm = objm;

        // 监听视口创建完成事件
        objm.viewerCreatedEvent.don((viewer) => {
            /**
             * 
             * pickPosition(screenPosition)：异步拾取参数像素点位置处的三维经纬高坐标
             *  参数1：screenPosition 像素点位置
             * 
             *  返回值：
             *  Promise对象      
             *  
            */
            // 监听点击事件
            viewer.clickEvent.don((e) => {
                viewer.pickPosition(e.screenPosition).then(res => {
                    document.getElementById('info').innerHTML = JSON.stringify(res);
                })
            })
        })

        // 创建Cesium视口
        const viewer = objm.createCesiumViewer({
            "domid": document.getElementById("app")
        })

        // 通过json创建一个影像图层
        const imageryLayer = objm.createSceneObjectFromJson({
            "id": "9812a65f-0de0-4f7b-b234-809c0c2fb8ef",
            "type": "ESImageryLayer",
            "maximumLevel": 18,
            "url": "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
        });



    </script>

    <!-- 切换UE和Cesium引擎的组件（Vue） -->
    <div id="root">
        <switch-engine :objm="objm"></switch-engine>
    </div>
    <!-- Vue文件 -->
    <script src="./js/vue.global.js"></script>
    <!-- 切换UE和Cesium的组件 -->
    <script src="./js/switchEngineCom.js"></script>
</body>

</html>